Skip to content

fix(parquet): clamp the Arrow reader batch size by row group rows - #12501

Open
linyiru wants to merge 1 commit into
apache:mainfrom
linyiru:fix-batch-size-clamp-row-group-rows
Open

linyiru wants to merge 1 commit into
apache:mainfrom
linyiru:fix-batch-size-clamp-row-group-rows

Conversation

@linyiru

@linyiru linyiru commented Nov 29, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

The Arrow reader clamps its batch size by FileMetaData.num_rows. parquet-testing/data/repeated_no_annotation.parquet has that count at 0 and six rows in its row group, so the batch size becomes 0 and ParquetRecordBatchReader returns no rows and no error. The record API and pyarrow read six rows.

What changes are included in this PR?

Both clamps, in ArrowReaderBuilder::with_batch_size and in ParquetRecordBatchReaderBuilder::build, use the number of rows the row groups declare. The clamp is there to avoid a large allocation for a small file, and the row groups are what the reader decodes.

Are these changes tested?

Yes. test_file_row_count_of_zero reads repeated_no_annotation.parquet with the default batch size and with an explicit one, and expects six rows. On main it gets zero.

Are there any significant user-facing changes?

A file whose file-level row count is lower than the total of its row groups now returns batches of the requested size, and all of its rows when that count is zero.

AI usage disclosure

Claude Code found the problem while fuzzing the reader with corrupted files, and generated the fix, the test and this description. The test was run on main with and without the fix.

🤖 Generated with Claude Code

The batch size was clamped by the file-level row count. A file that leaves that count at zero, such as repeated_no_annotation.parquet, was read as empty. The clamp now uses the rows the row groups declare.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@boring-cyborg boring-cyborg Bot added the parquet parquet crate label Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet: ParquetRecordBatchReader yields no rows for repeated_no_annotation.parquet (file-level num_rows of 0)

1 participant